/*
 //  TextDownloader.h
 //  TextDownloader
 //
 //  Created by Brennan Stehling on 10/25/09.
 //  Copyright 2009 SmallSharpTools LLC. All rights reserved.
 */

#import <Foundation/Foundation.h>

// declaration of an optional method for a delegate
@protocol TextDownloadDelegate
@optional
- (void) downloadTextFinished: (NSString *) text;
- (void) downloadTextFailed: (NSString *) errorMessage;
@end

@interface TextDownloader : NSObject <TextDownloadDelegate> {
    NSURLConnection *           _connection;
	NSString		*			_contentType;	
	NSMutableString *			_text;
	NSMutableArray	*			_supportedContentTypes;
	id							_delegate;
}

@property (nonatomic, readonly) BOOL				isReceiving;
@property (nonatomic, retain)   NSURLConnection *	connection;
@property (nonatomic, retain)   NSString		*	contentType;
@property (nonatomic, retain)   NSMutableString *	text;
@property (nonatomic, retain)   NSMutableArray	*	supportedContentTypes;
@property (nonatomic, retain)	id					delegate;

// private methods
- (void)_startReceive:(NSString *)urlString;
- (void)_stopReceiveWithStatus:(NSString *)errorMessage;

- (void)downloadText:(NSString *)urlString delegate:(id)delegate;
- (BOOL)isSupportedContentType;

@end
